/**
 * Created by Administrator on 2014/12/19.
 */
var Detail = (function(){
	var buyWrap = null;
	function init(){
		buyWrap = $("#buyWrap");
		buyWrap.on("click",".tbox",function(e){
			var target = $(e.target);
			var oprice = target.attr("data-oprice");
			var nprice = target.attr("data-nprice");
			var storage = target.attr("data-storage");
			selectTicket(target,oprice,nprice,storage);
			return false;
		}).on("click",".countGroup .btn",function(e){
			var target = $(e.target);
			if(target.hasClass("plus")){
				addCount();
			}else{
				minuCount();
			}
		})
	}
	//选择不同票类，变化价格，原价，库存
	function selectTicket(target,oprice,nprice,storage){
		if(!nprice) return;
		target.addClass("active").siblings().removeClass("active");
		$("#oprice").text(oprice);
		if(nprice){
			$("#opricew").show();
			$("#nprice").text(nprice);
		}else{
			$("#opricew").hide();
		}
		if(storage){
			$("#storagew").show();
			$("#storageCount").text(storage)
		}else{
			$("#storagew").hide();
		}
	}
	function addCount(){

	}
	function minuCount(){
		
	}

	return{
		init : init
	}

})();

$(function(){
	Detail.init()
})